package com.apes.autoparts.supplier.dataCenter;

import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * Created by lishikun on 2021/5/19 16:58
 */
public interface DCBusinessinfoContractRepository extends CustomRepository<DCBusinessinfoContrast, String> {
    @Modifying
    @Query(value = "delete\n" +
            "  from dc_businessinfo_contrast a " +
            " WHERE exists (select * " +
            "          from dc_businessinfo b " +
            "         where b.id = a.dc_businessinfo_id " +
            "           and b.SUPPLIER_PLATFORM_ITEM_ID = :supplierPlatformItemId " +
            "           and t.last_updated_stamp  > sysdate - (:hours / 24))   ",nativeQuery = true)
    int deleteBySupplierPlatformItemAndNotUpdate(@Param("supplierPlatformItemId") String supplierPlatformItemId, long hours);
}
